<template>
  <div>
    <Item @selfEvent="hahaha"></Item>
    <Person ref="selfPerson"></Person>
    <House ref="house"></House>

    <button @click="bindCustomFun">给house组建绑定自定义事件</button>
    <button @click="unbindCustomFun">解绑house组建的自定义事件</button>
  </div>
</template>

<script>
import Item  from "@/components/Item";
import Person  from "@/components/Person";
import House  from "@/components/House";
export default {
 
components:{
    Item,
    Person,
    House
},
methods:{
    hahaha(name){
        console.log(name);
    },
    haihai(name){
        console.log(name);
    },
    wakaka(msg){
        console.log("wakaka"+"信息是"+msg);
    },
    customFun(val){
        setTimeout(function(){
            console.log("王麻子,这是我家"+val);
        })
    },
    bindCustomFun(){
        this.$refs.house.$on("customFun",this.customFun)
    },
    unbindCustomFun(){
        this.$refs.house.$off("customFun")
    }
},
mounted(){
    // setTimeout(() => {
        this.$refs.selfPerson.$on("wakaka",this.wakaka)
    // }, 4000);
}
}
</script>

<style>

</style>